package org.netEase.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tomcat.jni.Buffer;
import org.netEase.dao.commentDao;
import org.netEase.dao.impl.commentDaoImple;
@WebServlet(urlPatterns= {"/totComCount.shtml"})
public class TotComCountAjax extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		commentDao commentDao = new commentDaoImple();
		request.setCharacterEncoding("utf-8");
		String sid = request.getParameter("sid");
		int totCountCom=commentDao.getTotCount(Integer.parseInt(sid));
		int havimgCount = commentDao.havimg(Integer.parseInt(sid));
		int five = commentDao.five(Integer.parseInt(sid));
		StringBuffer sb = new StringBuffer();
		sb.append("{");
		sb.append("totCountCom:"+totCountCom+",havimgCount:"+havimgCount+",five:"+five);
		sb.append("}");
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().print(sb.toString());
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
	}
}
